#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

#include<stdlib.h>
int* productExceptSelf(int* nums, int numsSize, int* returnSize) {
    int* arr = (int*)malloc(numsSize * sizeof(int));
    *returnSize = numsSize;
    arr[0] = 1;
    for (int i = 1; i < numsSize; i++)
    {
        arr[i] = nums[i - 1] * arr[i - 1];
    }
    int r = 1;
    for (int i = numsSize - 1; i >= 0; i--)
    {
        arr[i] = arr[i] * r;
        r = r * nums[i];
    }
    return arr;
}


int cmp(const void* a, const void* b)
{
    return *(int*)a - *(int*)b;
}
int* findDisappearedNumbers(int* nums, int numsSize, int* returnSize) {
    int* arr = (int*)malloc(numsSize * sizeof(int));
    *returnSize = 0;
    qsort(nums, numsSize, sizeof(int), cmp);
    for (int i = 1; i <= numsSize; i++)
    {
        int left = 0;
        int right = numsSize - 1;
        int flag = 0;
        while (left <= right)
        {
            int mid = (left + right) / 2;
            if (nums[mid] > i)
            {
                right = mid - 1;
            }
            else if (nums[mid] < i)
            {
                left = mid + 1;
            }
            else
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
        {
            arr[*returnSize] = i;
            (*returnSize)++;
        }
    }
    return arr;
}
int main()
{
    int arr[] = { 1,1 };
    int n = 0;
    int* a = findDisappearedNumbers(arr, 2, &n);
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
    return 0;
}